<?php
/**
 * Created by PhpStorm.
 * User: zjx
 * Date: 2016/11/25
 * Time: 10:32
 */

namespace App\Services\Utils;

use Carbon\Carbon;

class CheckOnSale
{

    public static function OnSaleTime( $type_product )
    {
        if ( $type_product->frozen == 1 ) return false;

        if ( Carbon::now() >= $type_product->sale_at && Carbon::now() < $type_product->sale_end )
        {
            return true;
        }elseif( Carbon::now() >= $type_product->sale_at &&  $type_product->sale_end=='-0001/11/30')
        {
            return true;
        }elseif ( Carbon::now() >= $type_product->sale_at &&  $type_product->sale_end=='0000-00-00 00:00:00' )
        {
            return true;
        }elseif ( Carbon::now() >= $type_product->sale_at &&  $type_product->sale_end==null )
        {
            return true;
        }
        else{
            return false;
        }

    }

}